Skip to content

feat(shot): report the device's locale with --locale - #52

Merged
koji-1009 merged 2 commits into
feat/brightness-text-scalefrom
feat/locale
Nov 5, 2026
Merged

koji-1009 merged 2 commits into
feat/brightness-text-scalefrom
feat/locale

Conversation

@koji-1009

Copy link
Copy Markdown
Owner

Stacked on #51.

flutter test reports en-US as the device's locale, so an app that resolves its locale from the device (its MaterialApp, CupertinoApp, or WidgetsApp against supportedLocales) was always shot in English, and a preview's localizations without a locale resolved to English too. A screen of a Japanese app attached to a PR was not the screen its users see.

How it works

  • shutter shot --locale <tag> (and semantics) reports that locale as the device's; from Dart, shot(locale: 'ja-JP'). The tag is a language (two or three letters), then an optional script and region, joined by - or _: ja-JP, ja_jp, zh-Hant-TW.
  • The harness sets localesTestValue and localeTestValue to the locale, so an app widget resolves its locale from it against its supportedLocales, as does a preview's LocalizationsResolver without a locale. An app widget that does not support the locale falls back as on a device; the default shell's MaterialApp supports only en-US.
  • shoot rejects anything else with exit 64.
  • The run records locale in manifest.json as a language tag with each code in its usual case (zh-Hant-TW), shot prints it, and diff prints both runs' when they differ and returns it as ShotSetup.locale. It is not part of shot ids.

Tests

  • test/e2e/device_test.dart: under --locale ja-JP, View.of(context).platformDispatcher.locale is ja_JP, and a preview whose localizations support en and ja resolves to ja; without it, neither; diff prints locale.

Docs

  • doc/manual.md gains a Locale section; runs, output, and commands name the option. doc/agent.md, the README, and the CHANGELOG cover it.

🤖 Generated with Claude Code

shot --locale <tag> (and semantics, and shot(locale:)) reports that
locale as the device's instead of en-US: a language, then an optional
script and region, such as ja-JP or zh-Hant-TW. The shell's app widget
resolves its locale from it against its supportedLocales, and so do a
preview's localizations that set no locale. The run records it as a
language tag, shot prints it, and diff prints both runs' when they
differ and returns it as ShotSetup.locale; it is not part of shot ids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@koji-1009

koji-1009 commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner Author

A --widget printing View.of(context).platformDispatcher.locale, shown at its logical width (240x40): the device's locale is flutter test's en-US by default and ja-JP with --locale ja-JP. example/'s shell uses MaterialApp's default supportedLocales (en-US only), so its own screens stay in English, as they would on a Japanese device.

default --locale ja-JP
device locale by default device locale with --locale ja-JP

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

A deprecated language or region (iw, BU) is recorded as dart:ui's
Locale replaces it (he, MM), since that is the locale the app gets, so
two runs that render alike no longer differ in locale. diff now quotes
the locale as shot does, so a YAML 1.1 reader takes Norwegian's `no`
for the string, not false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@koji-1009
koji-1009 marked this pull request as ready for review November 5, 2026 00:10
@koji-1009
koji-1009 added this pull request to stack #54 November 5, 2026 00:34
@koji-1009
koji-1009 merged commit b695199 into main Nov 5, 2026
5 checks passed
@koji-1009
koji-1009 deleted the feat/locale branch November 5, 2026 00:55
@koji-1009 koji-1009 mentioned this pull request Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants